Assuming sizeof(int) = 4 ::
My question is what 'y' would be following the code
int x = 0x1234567;
char *p = (char *)&x;
int y = (int)(*p);
(a) On a little endian machine
(b) On a big endian machine
---------------------------------------------------------
The answers are 103 for little endian and
1 for big endian.
However, I am confused how those are the answers. I understand in a little endian machine that the bits are stored from the least significant to the most, and vice-versa for big endian. Should I be converting x into binary at any point? And what is the purpose of the pointer being assigned to the address of x then being casted into an int? Any help would be nice, a little direction for me may help it click in my head.